﻿using Orchard.Data.Migration;

namespace Contrib.SecuredSocketsLayer {
    public class Migrations : DataMigrationImpl {
        public int Create() {

            SchemaBuilder.CreateTable("SslSettingsPartRecord", 
                table => table
                    .ContentPartRecord()
                    .Column<bool>("CustomEnabled")
                    .Column<bool>("AuthenticationEnabled")
                    .Column<bool>("AdminEnabled")
                    .Column<string>("Urls", c => c.Unlimited())
                    .Column<string>("SecureHostName")
                    .Column<string>("InsecureHostName")
                );

            return 3;
        }

        public int UpdateFrom1() {
            SchemaBuilder.DropTable("SslSettingsPartRecord");
            return Create();
        }

        public int UpdateFrom2() {
            SchemaBuilder.AlterTable("SslSettingsPartRecord",
                table => table.AddColumn<string>("SecureHostName"));
            SchemaBuilder.AlterTable("SslSettingsPartRecord",
                table => table.AddColumn<string>("InsecureHostName"));

            return 3;
        }
    }
}